package com.coder.algorithm.leetcode

/**
 * [27. 移除元素](https://leetcode-cn.com/problems/remove-element/)
 *
 * @author yuhus
 * @date: 2022/3/29
 */
object l_0027 {
    fun removeElement(nums: IntArray, `val`: Int): Int {
        var slow = 0
        var fast = 0
        for (fast in nums.indices) {
            if (nums[fast] != `val`) {
                nums[slow++] = nums[fast]
            }
        }
        return slow
    }
}